<template>
    <view class="cellBox">
        <view class="detail">
            <view class="flex_wrap row_between row_middle">
                <u-icon
                    name="https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/09/28/f3a97013cf124649ad85e6955f6ca338.png"
                    size="40rpx"
                    label="更多内容"
                    labelSize="36rpx"
                    labelColor="#3D3D3D"
                />
            </view>
            <!-- 列表 -->
            <view>
                <view
                    v-for="(item, index) in dataList"
                    :key="index"
                    @click="to_counsellingsDetail(item.id)"
                >
                    <view class="news_detail flex_wrap row_between">
                        <u-image
                            height="136rpx"
                            width="240rpx"
                            :src="item.videoCover"
                            mode="aspectFill"
                            radius="8rpx"
                        />
                        <view style="flex: 1; padding-left: 12rpx">
                            <text class="detail_t">{{
                                item.videoIntro
                            }}</text>
                            <u-text
                                :text="
                                   $u.timeFormat(
                                       item.uploadTime,
                                       'yyyy年mm月dd日'
                                   )
                                "
                                size="24rpx"
                                color="#666"
                                margin="26rpx 0 0 0"
                            />
                        </view>
                    </view>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
import { mapGetters } from "vuex";
import caches from "@/config/caches.js"
import { getVideoCounselling ,getVideoCounsellingLogin} from "@/api/enterprise.js"
import { baseUrl } from "@/config/tendIdConfig";
export default {
    data() {
        return {
            title: {
                marginLeft: "12rpx",
            },
            dataList: [],
			videoTypeId:'',
			styleFirstNum:''
        };
    },
    computed: {
        ...mapGetters(["userInfo"]),
    },
    onLoad(options) {
    	console.log(options,'gengduo')
		this.videoTypeId = options.videoTypeId
		this.styleFirstNum = options.styleFirstNum
		if(this.styleFirstNum == 2){
			this.getPersonInfo()
		}else{
			this.getVideoList(this.videoTypeId)
		}
    },
    methods: {
		
		async getPersonInfo() {
			const params = {
				pageNum: 1,
				pageSize: 1000,
				recordType: 1,
				healthMaster:1,
			}
			const result = uni.getStorageSync(caches.ACCESS_TOKEN) ?await getVideoCounsellingLogin(params) : await getVideoCounselling(params);
			this.dataList = result.data?.rows ?? []
		},
		to_counsellingsDetail(id,styleFirstNum){
			if (this.styleFirstNum == 0 || this.styleFirstNum == 1) {
				this.$u.route({
					url: "/pages_consultation/counsellings/ichrTextDetails",
					params: {
						id,
						styleFirstNum:this.styleFirstNum
					}
				})
			} else {
				console.log('1111')
				this.$u.route({
					url: "/pages_consultation/counsellings/detailsSalesman",
					params: {
						id,
					}
				})
			}
		},
		getVideoList(videoTypeId) {
		    const token =
		        this.$store.getters?.customer_token ||
		        uni.getStorageSync("customer_token");
		    const that = this;
		    uni.request({
		        url:
		            baseUrl +
		            "/customer/video_info_customer/open/pageVideoNoToken",
		        method: "POST",
		        header: {
		            Authorization: token,
		        },
		        data: {
		           pageNum: 1,
		           pageSize: 1000,
		            videoTypeId
		        },
		        success(res) {
		            const result = res.data.data?.rows ?? [];
		            that.dataList = result;
		        },
		    });
		},
    },
};
</script>

<style scoped lang="scss">
.cellBox {
    padding: 24rpx 28rpx;
}

.detail {
    padding: 20rpx;
}

.upload {
    width: 154rpx;
    height: 60rpx;
    background: #f3f9ff;
    border-radius: 4000rpx 4000rpx 4000rpx 4000rpx;
}
.news_detail {
    padding: 24rpx 0 3rpx;
}

.detail_t {
    display: block;
    width: 412rpx;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: 28rpx;
    color: #3d3d3d;
}
</style>
